package com.lifo.shoppingcart.dao;

import com.lifo.shoppingcart.bean.HfShoppingCart;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by Administrator on 2018/6/25 0025.
 */
@Mapper
public interface ShoppingCartManagerMapper {
    /**
     * 保存商品至购物车
     * @param hfShoppingCart
     */
    void saveShoppingCart(HfShoppingCart hfShoppingCart);

    /**
     * 根据userId查询用户购物车中的商品
     * @param userId
     * @return
     */
    List<HfShoppingCart> searchHfShoppingCartsByUserId(int userId);

    /**
     * 查询购物车商品,通过userId,分组
     * where user_id =? group by shop_id,hf_good_id,color,size,good_title,taobao_price,wholesale_price
     * @param userId
     * @return
     */
    List<HfShoppingCart> searchHfShoppingCartsByUserIdGroupByConditions(int userId);

    /**
     * 根据购物车中单个商品的主建查询商品
     * @param cartId
     * @return
     */
    @Select("select * from hf_shopping_cart where cart_id = #{cartId} ")
    HfShoppingCart searchHfShoppingCartByCartId(@Param("cartId")  int cartId);

    /**
     * 统计购物商品数量
     * @param userId
     * @return
     */
    int countByUserId(int userId);

}
